<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>iframe嵌入的页面</h1>
</body>
<script>
    window.addEventListener('message', ev => {
        const { data, origin, source } = ev
        if (origin !== 'http://localhost:5000') return
        console.log('接收到index页面发送的消息:', data)
        source.postMessage('给index页面发送的消息', origin)
    })
</script>

</html>